package com.ocom.payconfig.controller;

import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.entity.payconfig.EntityReceiptAddressPrice;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.payconfig.service.ReceiptAddressPriceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class ReceiptAddressPriceController {

    @Autowired
    private ReceiptAddressPriceService receiptAddressPriceService;

    @PostMapping(PayConfigUrl.Url_setReceiptAddressPrice)
    public Result setReceiptAddressPrice(@RequestBody EntityReceiptAddressPrice addressPrice){
        this.receiptAddressPriceService.setReceiptAddressPrice(addressPrice.getComId(), addressPrice);
        return ResultUtil.success();
    }

    @PostMapping(PayConfigUrl.Url_removeReceiptAddressPrice)
    public Result removeReceiptAddressPrice(@RequestBody EntityReceiptAddressPrice addressPrice){
        this.receiptAddressPriceService.removeReceiptAddressPrice(addressPrice.getComId(), addressPrice);
        return ResultUtil.success();
    }

    @PostMapping(PayConfigUrl.Url_getReceiptAddressPriceList)
    public Result getReceiptAddressPriceList(@RequestBody EntityReceiptAddressPrice addressPrice){
        return ResultUtil.success(this.receiptAddressPriceService.getReceiptAddressPriceList(addressPrice.getComId(), addressPrice));
    }
}
